/**
 * Asserts that arguments are equal.
 * Compares primitive, array & object (recursivelly).
 * 
 *  @param Any argA
 *  @param Any argB
 */
Assert.equal = function( argA, argB )
{
	Assert._increment( );
	Assert.equal.type( argA, argB );
	
	switch( Lang.type( argA ) )
	{
		case "array":
			Assert.equal.collection( argA, argB );
			break;
		
		case "object":
			if( Assert.equal.custom( argA, argB ) ) { break; }
			Assert.equal.collection( argA, argB );
			break;
			
		case "date":	
			DateAssert.datesAreEqual( argA, argB );
			DateAssert.timesAreEqual( argA, argB );
			break;
			
		default: 
			Assert.same( argA, argB ); 
			break;
	}
};

/**
 * Asserts that arguments types are the same.
 * 
 *  @param Any argA
 *  @param Any argB
 */
Assert.equal.type = function( argA, argB )
{
	var typeA, typeB;
	
	typeA = Lang.type( argA );
	typeB = Lang.type( argB );
	
	Assert.yes( typeA === typeB, "Assert.equal: Types don't match: '" + typeA + "' vs '" + typeB + "'" );
};

/**
 * Asserts that collections are equal.
 * 
 *  @param Collection argA
 *  @param Collection argB
 */
Assert.equal.collection = function( argA, argB )
{
	Assert.equal.size( argA, argB );
	
	function loop( item, i ) { Assert.equal( item, argB[ i ] ); }
	
	if( Lang.isArray( argA ) ) { Array.each( argA, loop ); }
	if( Lang.isObject( argB ) ) { Object.each( argA, loop ); }
};

/**
 * Asserts that collections size are the same.
 * 
 *  @param Collection argA
 *  @param Collection argB
 */
Assert.equal.size = function( argA, argB )
{
	var 	sizeA = argA.length || Object.size( argA ),
			sizeB = argB.length || Object.size( argB );
	
	Assert.yes( sizeA === sizeB, "Assert.equal: Sizes don't match: '" + sizeA + "' vs '" + sizeB + "'" );
};

/**
 * Asserts that objects are equal by using custom equals function.
 * 
 *  @param Object argA
 *  @param Object argB
 */
Assert.equal.custom = function( argA, argB )
{
	if( !argA.equals ) { return false; }
	
	Assert.yes( argA.equals( argB ), "Assert.equal: Custom compare failed: '" + Env.dump( argA ) + "' vs '" + Env.dump( argB ) + "'" );
	return true;
};
